<template>
	<view :data-theme='theme()' :class="theme() || ''">
		<view class="order-list">
			<view class="item" v-for="(item, index) in listData" :key="index">
				<view class="d-b-c pb38">
					<view class="item-dianpu" @click="toShop(item.supplier.shop_supplier_id)">
						<view class="item-d-l mr10">
							<i class="icon iconfont icon-dianpu1"></i>
							<text class="fb gray3 f32" v-if="item.supplier">{{item.supplier.name}}</text>
						</view>
						<view>
							<i class="icon iconfont icon-jiantou"></i>
						</view>
					</view>
					<view class="state">
						<text class="redF6"
							style="color: #2b85e4;">{{ item.order_status.value == 40?'已驳回':item.state_text }}</text>
					</view>
				</view>
				<view class="order-head d-b-c">
					<view>
						<text class="shop-name flex-1 fb">订单号：{{ item.order_no }}</text>
					</view>
				</view>

				<!--多个商品显示-->
				<view class="product-list pr" v-if="item.product.length > 1" @click="gotoOrder(item.order_id)">
					<scroll-view scroll-x="true">
						<view class="list d-s-c pr100">
							<view class="cover mr10" v-for="(img, num) in item.product" :key="num">
								<image :src="img.image.file_path" mode="aspectFit"></image>
							</view>
						</view>
					</scroll-view>
					<view class="total-count">
						<view class="left-shadow"></view>
						<view class="price f24">
							¥
							<text class="f32">{{ item.pay_price}}</text>
						</view>
						<view class="count">共{{ item.product.length }}件</view>
					</view>
				</view>

				<!--一个商品显示-->
				<view class="one-product d-s-c" v-else @click="gotoOrder(item.order_id)">
					<view class="cover" v-for="(img, num) in item.product" :key="num">
						<image :src="img.image.file_path" mode="aspectFit"></image>
					</view>
					<view class="pro-info flex-1">{{ item.product[0].product_name }}</view>
					<view class="total-count">
						<view class="left-shadow"></view>
					</view>
				</view>

				<view style="display: flex;justify-content: flex-end;">
					<view class="count2">总租金: <span
							style="color: #46454E;font-weight: 700;font-size: 34rpx;margin: 0 15rpx;">¥
							{{ (item.total_price - item.deposit - item.zhuanzujin).toFixed(2) }}</span> 共12期 </view>
				</view>
			</view>
			<view class="p30" style="text-align: center;display: flex;flex-direction: column;align-items: center;"
				v-if="tokendata==''">
				<text class="iconfont icon-wushuju"></text>
				<text class="cont">亲，还没有登录哦</text>

			</view>
			<view v-if="listData.length == 0 && !loading" style="text-align: center;">
				<view class="cont"
					style="display: flex;margin-top: 20rpx;justify-content: center;align-items: center;color: #2979ff;">
					<u-icon name="warning" color="#2979ff" size="28"></u-icon> 亲，暂无相关记录哦
				</view>
			</view>
			<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
		</view>

		<u-popup :show="showqx" mode="bottom" @close="close" closeable=true>
			<view style="height: 600rpx;">
				<view class="yuanyin">请选择取消原因</view>
				<view class="fxuankuang">
					<u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange">
						<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in checkboxList1"
							:key="index" :label="item.name" :name="item.name">
						</u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="anniuXq">
					<button @click="queding">确认</button>
					<button @click="close">取消</button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import Popup from '@/components/uni-popup.vue';
	import uniLoadMore from '@/components/uni-load-more.vue';
	import {
		pay
	} from '@/common/pay.js';
	export default {
		components: {
			Popup,
			uniLoadMore
		},
		data() {
			return {
				state_text: "",
				text1: "补充信息可加速审核，大幅提高审核通过率",
				tokendata: "",
				checkboxValue1: [],
				// 基本案列数据
				checkboxList1: [{
						name: '押金过高',
						disabled: false
					},
					{
						name: '更改订单信息',
						disabled: false
					},
					{
						name: '预收押金/补押金',
						disabled: false
					},
					{
						name: '审核时间过长',
						disabled: false
					},
					{
						name: '商家没货/服务态度问题',
						disabled: false
					},
					{
						name: '运费问题',
						disabled: false
					}
				],
				showqx: false,
				/*手机高度*/
				phoneHeight: 0,
				/*可滚动视图区域高度*/
				scrollviewHigh: 0,
				/*状态选中*/
				state_active: 0,
				/*顶部刷新*/
				topRefresh: false,
				/*数据*/
				listData: [],
				tabNumber: 0,
				/*数据类别*/
				dataType: 'all',
				/*是否显示支付类别弹窗*/
				isPayPopup: false,
				/*支付方式*/
				pay_type: 20,
				/*订单id*/
				order_id: 0,
				/*最后一页码数*/
				last_page: 0,
				/*当前页面*/
				page: 1,
				/*每页条数*/
				list_rows: 10,
				/*有没有等多*/
				no_more: false,
				/*是否正在加载*/
				loading: true,
				/*是否显示核销二维码*/
				isCodeImg: false,
				codeImg: '',
				/*是否显示支付宝支付，只有在h5，非微信内打开才显示*/
				showAlipay: false,
				isfirst: false
			};
		},
		onReachBottom() {
			let self = this
			/*获取订单列表*/
			self.page++
			self.getData();
		},
		computed: {
			/*加载中状态*/
			loadingType() {
				if (this.loading) {
					return 1;
				} else {
					if (this.listData.length != 0 && this.no_more) {
						return 2;
					} else {
						return 0;
					}
				}
			}
		},
		onLoad(e) {
		},
		mounted() {
			this.init();
			this.initData();
			/*获取订单列表*/
			this.getData();
			this.tokendata = uni.getStorageSync('token');
			console.log("tokendata", this.tokendata);
		},
		onShow() {
			if (this.isfirst) {
				this.initData();
				this.getData();
			}
		},
		methods: {
			denglu() {
				uni.navigateTo({
					url: "/pages/user/index/phoneLogin"
				})
			},
			checkboxChange() {
				// console.log(this.checkboxValue1);
			},
			close() {
				this.showqx = false;
			},
			qrz(id) {
				uni.navigateTo({
					url: '/pages/order/smrz?order_id=' + id
				})
			},
			initData() {
				let self = this;
				self.page = 1;
				self.listData = [];
				self.no_more = false;
			},
			/*初始化*/
			init() {
				let self = this;
				uni.getSystemInfo({
					success(res) {
						self.phoneHeight = res.windowHeight;
						// 计算组件的高度
						let view = uni.createSelectorQuery().in(self).select('.top-tabbar');
						view.boundingClientRect(data => {
							let h = self.phoneHeight - data.height;
							self.scrollviewHigh = h;
						}).exec();
					}
				});
			},

			/*可滚动视图区域到底触发*/
			scrolltolowerFunc() {
				let self = this;
				if (self.no_more) {
					return;
				}
				self.page++;
				if (self.page <= self.last_page) {
					self.getData();
				} else {
					self.no_more = true;
				}
			},

			/*获取数据*/
			getData() {
				// console.log("token",uni.getStorageSync('token'));
				let self = this;
				if (!uni.getStorageSync('token')) {
					self.loading = false;
					return
				}
				self.loading = true;
					self._get(
						'user.order/tglists', {
							page: self.page,
							pay_source: self.getPlatform(),
							list_rows: self.list_rows
						},
						function(res) {
							console.log("res",res);
							self.loading = false;
							self.listData = self.listData.concat(res.data.list.data);
							self.last_page = res.data.list.last_page;
						}
					);
			},

			/*跳转页面*/
			gotoOrder(e) {
				// uni.navigateTo({
				// 	url: '/pages/order/order-detail?order_id=' + e
				// })
			},



		}
	};
</script>

<style lang="scss">
	.yuanyin {
		text-align: center;
		margin-bottom: 20rpx;
		color: #A5A5A5;
		border-bottom: 1rpx solid #A5A5A5;
		padding: 23rpx;
	}

	.fxuankuang {
		padding: 20rpx 40rpx;
	}

	.anniuXq {
		display: flex;
		justify-content: center;

		button {
			width: 50%;
		}
	}

	.contact_button {
		border: 1px solid #000000;
		border-radius: 10rpx;
		width: 160rpx;
		height: 60rpx;
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 22rpx;
		color: #000000;
	}

	.contact_button text {
		margin-right: 10rpx;
	}

	page {
		background-color: #f2f2f2;
	}

	.order-list .order-head .state-text {
		padding: 10rpx 12rpx;
		margin-right: 21rpx;
		border-radius: 4rpx;
		background: #FFE7E4;
		font-size: 22rpx;
		color: #F6220C;
	}

	.shop-name {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.order-list .item {
		margin-bottom: 30rpx;
		padding: 30rpx;
		background: #ffffff;
	}

	.order-list .product-list,
	.order-list .one-product {
		padding: 30rpx 0 27rpx 0;
		height: 150rpx;
	}

	.one-product .pro-info {
		padding: 0 21rpx 0 37rpx;
		display: -webkit-box;
		width: 361rpx;
		overflow: hidden;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		font-size: 26rpx;
		color: #333333;
	}

	.order-list .cover,
	.order-list .cover image {
		width: 150rpx;
		height: 150rpx;
		border-radius: 8rpx;
	}

	.order-list .total-count {
		padding-left: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: flex-end;
	}

	.total-count .count {
		padding-top: 16rpx;
		color: #999999;
		font-size: 22rpx;
	}

	.count2 {
		padding-top: 16rpx;
		color: black;
		font-size: 26rpx;
	}

	.product-list .total-count {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		background: rgba(255, 255, 255, 0.9);
	}

	.product-list .total-count .left-shadow {
		position: absolute;
		top: 0;
		bottom: 0;
		left: -24rpx;
		width: 24rpx;
		overflow: hidden;
	}

	.product-list .total-count .left-shadow::after {
		position: absolute;
		top: 0;
		bottom: 0;
		width: 24rpx;
		right: -12rpx;
		display: block;
		content: '';
		background-image: radial-gradient(rgba(0, 0, 0, 0.2) 10%, rgba(0, 0, 0, 0.1) 40%, rgba(0, 0, 0, 0) 80%);
	}

	.order-list .order-bts {
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.order-list .order-bts button {
		margin: 0;
		padding: 0 20rpx;
		height: 50rpx;
		line-height: 50rpx;
		margin: 0 8rpx;
		margin-bottom: 2rpx;
		font-size: 22rpx;
		border: 1px solid #000000;
		border-radius: 5px;
		background: #ffffff;
		white-space: nowrap;
		color: #000000;
		font-family: PingFang SC;
		// border:none;
	}

	.order-list .order-bts button::after {
		display: none;
	}

	.order-list .order-bts button.btn-border-red {
		border: 1px solid $dominant-color;
		font-size: 24rpx;
		color: $dominant-color;
	}

	.order-list .order-bts button.btn-red {
		background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
		border-radius: 30rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		color: #ffffff;
		border: none;
	}

	.buy-checkout {
		width: 100%;
	}

	.buy-checkout .item {
		min-height: 50rpx;
		line-height: 50rpx;
		padding: 20rpx;
		display: flex;
		justify-content: space-between;
		font-size: 28rpx;
	}

	.buy-checkout .iconfont.icon-weixin {
		color: #04be01;
		font-size: 50rpx;
	}

	.buy-checkout .iconfont.icon-yue {
		color: #f0de7c;
		font-size: 50rpx;
	}

	.buy-checkout .item.active .iconfont.icon-xuanze {
		color: #04be01;
	}

	.item-dianpu {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 24rpx;
		line-height: 30rpx;
	}

	.item-dianpu .icon-jiantou {
		font-size: 24rpx;
		color: #333333;
	}

	.item-d-l {
		display: flex;
	}

	.icon-dianpu1 {
		margin-right: 20rpx;
		color: #333333;
		font-size: 32rpx;
	}

	.top-tabbar {
		white-space: nowrap;
		padding: 5rpx 0;

		.main {
			display: flex;
			flex-direction: row;

			.active {
				background-color: #FFF6E5;
				color: #FCAA04;
				font-weight: bold;
				box-shadow: 0 5rpx 0 #F7AC18;
			}
		}
	}

	.tab-item {
		flex: 1;
		height: 70rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 30rpx;
		color: #999999;
		margin: 0 12rpx;
		background-color: #F1F2F6;
		padding: 0 30rpx;
		border-radius: 15rpx;

	}

	.tab-item:nth-last-child(1) {
		padding-right: 50rpx;
	}
</style>